﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiMaterialTextureLoadPE : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiMaterialTextureLoadPE(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiMaterialTextureLoadPE_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiMaterialTextureLoadPE obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiMaterialTextureLoadPE()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiMaterialTextureLoadPE(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiMaterialTextureLoadPE cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureLoadPE_cast(OdRxObject.getCPtr(pObj));
			OdGiMaterialTextureLoadPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureLoadPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureLoadPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureLoadPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMaterialTextureLoadPE_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMaterialTextureLoadPE_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMaterialTextureLoadPE_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiMaterialTextureLoadPE createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureLoadPE_createObject();
			OdGiMaterialTextureLoadPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureLoadPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureLoadPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureLoadPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void startTextureLoading(ref string fileName, OdRxObject pDb)
		{
			IntPtr intPtr = Marshal.StringToCoTaskMemUni(fileName);
			IntPtr value = intPtr;
			try
			{
				GlobalsPINVOKE.OdGiMaterialTextureLoadPE_startTextureLoading(this.swigCPtr, ref intPtr, OdRxObject.getCPtr(pDb));
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
			finally
			{
				if (intPtr != value)
				{
					fileName = Marshal.PtrToStringUni(intPtr);
				}
			}
		}

		public virtual void textureLoaded(string fileName, OdRxObject pDb)
		{
			GlobalsPINVOKE.OdGiMaterialTextureLoadPE_textureLoaded(this.swigCPtr, fileName, OdRxObject.getCPtr(pDb));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void textureLoadingFailed(string fileName, OdRxObject pDb)
		{
			GlobalsPINVOKE.OdGiMaterialTextureLoadPE_textureLoadingFailed(this.swigCPtr, fileName, OdRxObject.getCPtr(pDb));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
